// pages/loading/loading.js

const app = getApp()
Page({

    /**
     * 页面的初始数据
     */
    data: {
        types: null,
        presen_situation: null,
        xintai: null,
        is_active: null,
        is_help: null,
        options: null,
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.data.options = options
        console.log(options);
        /** 老版本逻辑
        let types = options.types
        console.log('loading页面参数::', options)
        this.setData({
            types: types,
            presen_situation: options.presen_situation,
            xintai: options.xintai,
            is_active: options.is_active,
            is_help: options.is_help
        })
         */
    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow: function () {
        let history_id = this.data.options.history_id
        let cid3 = this.data.options.cid3
        let xztype = this.data.options.xztype
        let xzdata1 = this.data.options.xzdata1
        let question_id = this.data.options.question_id
        let types = wx.getStorageSync('type');
        console.log('loading计数器1::', types);
        // 项目预测: 1 + 公关审核: 4 = 跳转页面不变
        let baseUrl = '/pages/result5/index';
        // // 工作事业选择: 2
        // if (cid3 == 8) baseUrl = '/pages/works/works';
        // // 情感选择: 3
        // if (cid3 == 9) baseUrl = '/pages/emotion/emotion';


        setTimeout(() => {
            app.show(this, 'show', 1);
            setTimeout(() => {
                wx.redirectTo({
                    url: baseUrl+'?history_id='+history_id + '&cid3=' + cid3+'&xzdata1='+xzdata1+'&xztype='+xztype+'&question_id='+question_id+'&flag=100',
                })
                // return
                // if (this.data.types) {
                //     wx.navigateTo({
                //         url: baseUrl + '?types=' + this.data.types,
                //     })
                // } else {
                //     wx.navigateTo({
                //         url: baseUrl,
                //     })
                // }
            }, 2000);
        }, 1000);
        /**老版本逻辑
        let types = this.data.types
        console.log('loading计数器1::', types)
        setTimeout(() => {
            app.show(this, 'show', 1)
            setTimeout(() => {
                var queryStr = 'presen_situation=' + this.data.presen_situation + '&xintai=' + this.data.xintai + '&is_active=' + this.data.is_active + '&is_help=' + this.data.is_help;              
                if(this.data.types) {
                    wx.navigateTo({
                        url: '/pages/newResults/newResults?types=' + this.data.types + '&' + queryStr,
                    })
                }else{
                    wx.navigateTo({
                        url: '/pages/newResults/newResults' + '?' + queryStr,
                    })
                }
            }, 2000);
        }, 1000);
         */
    },
    onHide: function () {
        setTimeout(() => {
            app.show(this, 'show', 0)
        }, 2000);
    }
})